package Vue.Menu;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.Observable;
import java.util.Observer;

import javax.imageio.ImageIO;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;

import LookAndFeel.Bouton;

public class MenuPrincipal extends JPanel{

	private static final long serialVersionUID = 1L;
	Image img;

	public MenuPrincipal(final CardLayout cl, final JPanel p) {
		this.setLayout(new BorderLayout());
		Box panel = new Box(BoxLayout.Y_AXIS);
		panel.setBackground(Color.BLACK);
		this.setSize(800, 600);
		try {
	       	 img = ImageIO.read(new File("./src/Images/Menu/ecran.jpg"));
	    }catch (IOException e) {
	         e.printStackTrace();
	    } 
	    /*Bouton newGame*/
	    Bouton nouveau = new Bouton("./src/Images/Menu/newGame.jpg");
	    nouveau.addActionListener(new ActionListener() {					
			@Override
			public void actionPerformed(ActionEvent arg0) {
				cl.next(p);
				cl.show(p, "Nouvelle partie");
			}
		});
	    panel.add(nouveau);
	    /*Bouton loadGame*/
	    Bouton load = new Bouton("./src/Images/Menu/loadGame.jpg");
	    load.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				cl.next(p);
				cl.show(p, "Charger une partie");
			}
		});
	    panel.add(load);
	    /*Bouton quitter*/
	    Bouton quit = new Bouton("./src/Images/Menu/quit.jpg");			
	    quit.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				System.exit(0);
			}
		});
	    panel.add(Box.createVerticalStrut(210));
	    panel.add(quit);
	    
	    this.add(Box.createHorizontalStrut(532), BorderLayout.WEST);
	    this.add(panel, BorderLayout.CENTER);	    
	}
	
	

	public void paint(Graphics g){
		g.drawImage(img, 0, 0, null);
	}

}
